<template>
    <el-row>
        <el-col :span="24">
            <el-form :inline="true"
                :model="rechargeSearchObj"
                class="search_prod tl">

                <el-form-item label="">
                    <el-input size="small"
                        clearable
                        v-model="rechargeSearchObj.username"
                        placeholder="创建人账号"></el-input>
                </el-form-item>

                <el-form-item label="">
                    <el-input type='text'
                        size="small"
                        clearable
                        v-model="rechargeSearchObj.nickname"
                        placeholder="创建人昵称"></el-input>
                </el-form-item>

                <el-form-item label="">
                    <el-select v-model="rechargeSearchObj.is_show"
                        clearable
                        size="small"
                        placeholder="激活状态">
                        <el-option v-for="item in statusList"
                            size="small"
                            :key="item.id"
                            :label="item.title"
                            :value="item.id">
                        </el-option>
                    </el-select>
                </el-form-item>

                <!-- <el-form-item label="" class="" >
                        <el-date-picker
                        style="width:100%"
                            v-model="createTime"
                            type="datetimerange"
                            size="small"
                            align="right"
                            unlink-panels
                            value-format="timestamp"
                            range-separator="-"
                            clearable
                            start-placeholder="充值时间起"
                            end-placeholder="充值时间止"
                            :picker-options="pickerOptions2">
                        </el-date-picker> 
                    </el-form-item> -->
                <el-form-item label="">
                    <el-row class="tl">
                        <el-col :span="24">
                            <el-button :loading='$store.state.isLoading'
                                size="small"
                                class="top_weiy"
                                type="primary"
                                @click="onSubmit">查询</el-button>
                            <el-button :loading='$store.state.isLoading'
                                size="small"
                                class="top_weiy"
                                type="primary"
                                @click="delSubmit">一键清除</el-button>
                        </el-col>
                    </el-row>
                </el-form-item>
            </el-form>
        </el-col>
    </el-row>
</template>
<script>
export default {
  name: "productSearch",
  data() {
    return {
      pickerOptions2: {
        disabledDate(time) {
          return time.getTime() > Date.now();
        },
        shortcuts: [
          {
            text: "最近一周",
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
              picker.$emit("pick", [start, end]);
            }
          },
          {
            text: "最近一个月",
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
              picker.$emit("pick", [start, end]);
            }
          },
          {
            text: "最近三个月",
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
              picker.$emit("pick", [start, end]);
            }
          }
        ]
      },
      rechargeSearchObj: {
        nickname: "",
        username: "",
        is_show: "",
        created_time_begin: "",
        created_time_end: ""
      },
      createTime: [],
      statusList: [{ id: 0, title: "未激活" }, { id: 1, title: "已激活" }]
    };
  },
  methods: {
    delSubmit() {
      this.rechargeSearchObj = {
        nickname: "",
        username: "",
        is_show: "",
        created_time_begin: "",
        created_time_end: ""
      };
      this.$emit("sendSearch", this.rechargeSearchObj);
    },
    onSubmit() {
      this.$emit("sendSearch", this.rechargeSearchObj);
    }
  },
  created() {},
  watch: {
    createTime(val) {
      if (val != null) {
        this.rechargeSearchObj.created_time_begin = this.$fnc.phptime(val[0]);
        this.rechargeSearchObj.created_time_end = this.$fnc.phptime(val[1]);
      } else {
        this.rechargeSearchObj.created_time_begin = "";
        this.rechargeSearchObj.created_time_end = "";
      }
    }
  }
};
</script>
